🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / core / domain / src / commonMain / kotlin / org / meshtastic / core / domain / usecase / settings / RadioConfigUseCase.kt
Displaying Raw • Download
core/domain/src/commonMain/kotlin/org/meshtastic/core/domain/usecase/settings/RadioConfigUseCase.kt 2d20cd8a4708e2ef66e98d5259f3a97ec93f240a (2d20cd8a) Text, 9.84 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.domain.usecase.settings
Tff7b72import T7ee787org.koin.core.annotation.Single
Tff7b72import T7ee787org.meshtastic.core.model.Position
Tff7b72import T7ee787org.meshtastic.core.repository.RadioController
Tff7b72import T7ee787org.meshtastic.proto.Config
Tff7b72import T7ee787org.meshtastic.proto.HamParameters
Tff7b72import T7ee787org.meshtastic.proto.ModuleConfig
Tff7b72import T7ee787org.meshtastic.proto.User
T8b949e/**
* Use case for interacting with radio configuration components.
*
* Every request method takes an [onRequestId] callback invoked with the request's packet ID *before* the send is
* issued. Callers that correlate responses by request ID (e.g. `RadioConfigViewModel.requestIds`) MUST register the ID
* in this callback rather than after the method returns: the send suspends until the radio acks the packet via
* `QueueStatus`, and for the locally connected node the firmware (2.8+) delivers the admin response through its
* synchronous loopback *before* that ack — so a post-return registration loses the race and the response is dropped.
*/
Tf0883e@SuppressTb4b4b4(Ta5d6ff"Ta5d6ffTooManyFunctionsTa5d6ff"Tb4b4b4)
Tf0883e@Single
Tff7b72open Tff7b72class T56d364RadioConfigUseCase Tff7b72constructorTb4b4b4(Tff7b72private Tff7b72val Te6edf3radioControllerTb4b4b4: Te6edf3RadioControllerTb4b4b4) Tb4b4b4{
T8b949e/**
* Updates the owner information on the radio.
*
* @param destNum The node number to update.
* @param user The new user configuration.
* @param onRequestId Invoked with the request's packet ID before the send is issued.
* @return The packet ID of the request.
*/
Tff7b72open Tff7b72suspend Tff7b72fun Td2a8ffsetOwnerTb4b4b4(Te6edf3destNumTb4b4b4: Tffa657IntTb4b4b4, Te6edf3userTb4b4b4: Te6edf3UserTb4b4b4, Te6edf3onRequestIdTb4b4b4: Tb4b4b4(Tffa657IntTb4b4b4) Tff7b72-Tff7b72> Tffa657Unit Tff7b72= Tb4b4b4{Tb4b4b4}Tb4b4b4)Tb4b4b4: Tffa657Int Tb4b4b4{
Tff7b72val Te6edf3packetId Tff7b72= Te6edf3radioControllerTb4b4b4.Te6edf3generatePacketIdTb4b4b4(Tb4b4b4)
Te6edf3onRequestIdTb4b4b4(Te6edf3packetIdTb4b4b4)
Te6edf3radioControllerTb4b4b4.Te6edf3setOwnerTb4b4b4(Te6edf3destNumTb4b4b4, Te6edf3userTb4b4b4, Te6edf3packetIdTb4b4b4)
Tff7b72return Te6edf3packetId
Tb4b4b4}
T8b949e/**
* Enables amateur-radio (ham) mode on the locally connected node via `set_ham_mode`. At protobufs 2.7.25 only
* `call_sign` and `short_name` are user-supplied; `long_name` becomes settable when meshtastic/protobufs#941 ships.
*
* @param destNum The node number to update (must be the local node).
* @param hamParameters The ham onboarding parameters.
* @param onRequestId Invoked with the request's packet ID before the send is issued.
* @return The packet ID of the request.
*/
Tff7b72open Tff7b72suspend Tff7b72fun Td2a8ffsetHamModeTb4b4b4(Te6edf3destNumTb4b4b4: Tffa657IntTb4b4b4, Te6edf3hamParametersTb4b4b4: Te6edf3HamParametersTb4b4b4, Te6edf3onRequestIdTb4b4b4: Tb4b4b4(Tffa657IntTb4b4b4) Tff7b72-Tff7b72> Tffa657Unit Tff7b72= Tb4b4b4{Tb4b4b4}Tb4b4b4)Tb4b4b4: Tffa657Int Tb4b4b4{
Tff7b72val Te6edf3packetId Tff7b72= Te6edf3radioControllerTb4b4b4.Te6edf3generatePacketIdTb4b4b4(Tb4b4b4)
Te6edf3onRequestIdTb4b4b4(Te6edf3packetIdTb4b4b4)
Te6edf3radioControllerTb4b4b4.Te6edf3setHamModeTb4b4b4(Te6edf3destNumTb4b4b4, Te6edf3hamParametersTb4b4b4, Te6edf3packetIdTb4b4b4)
Tff7b72return Te6edf3packetId
Tb4b4b4}
T8b949e/**
* Requests the owner information from the radio.
*
* @param destNum The node number to query.
* @param onRequestId Invoked with the request's packet ID before the send is issued.
* @return The packet ID of the request.
*/
Tff7b72open Tff7b72suspend Tff7b72fun Td2a8ffgetOwnerTb4b4b4(Te6edf3destNumTb4b4b4: Tffa657IntTb4b4b4, Te6edf3onRequestIdTb4b4b4: Tb4b4b4(Tffa657IntTb4b4b4) Tff7b72-Tff7b72> Tffa657Unit Tff7b72= Tb4b4b4{Tb4b4b4}Tb4b4b4)Tb4b4b4: Tffa657Int Tb4b4b4{
Tff7b72val Te6edf3packetId Tff7b72= Te6edf3radioControllerTb4b4b4.Te6edf3generatePacketIdTb4b4b4(Tb4b4b4)
Te6edf3onRequestIdTb4b4b4(Te6edf3packetIdTb4b4b4)
Te6edf3radioControllerTb4b4b4.Te6edf3getOwnerTb4b4b4(Te6edf3destNumTb4b4b4, Te6edf3packetIdTb4b4b4)
Tff7b72return Te6edf3packetId
Tb4b4b4}
T8b949e/**
* Updates a configuration section on the radio.
*
* @param destNum The node number to update.
* @param config The new configuration.
* @param onRequestId Invoked with the request's packet ID before the send is issued.
* @return The packet ID of the request.
*/
Tff7b72open Tff7b72suspend Tff7b72fun Td2a8ffsetConfigTb4b4b4(Te6edf3destNumTb4b4b4: Tffa657IntTb4b4b4, Te6edf3configTb4b4b4: Te6edf3ConfigTb4b4b4, Te6edf3onRequestIdTb4b4b4: Tb4b4b4(Tffa657IntTb4b4b4) Tff7b72-Tff7b72> Tffa657Unit Tff7b72= Tb4b4b4{Tb4b4b4}Tb4b4b4)Tb4b4b4: Tffa657Int Tb4b4b4{
Tff7b72val Te6edf3packetId Tff7b72= Te6edf3radioControllerTb4b4b4.Te6edf3generatePacketIdTb4b4b4(Tb4b4b4)
Te6edf3onRequestIdTb4b4b4(Te6edf3packetIdTb4b4b4)
Te6edf3radioControllerTb4b4b4.Te6edf3setConfigTb4b4b4(Te6edf3destNumTb4b4b4, Te6edf3configTb4b4b4, Te6edf3packetIdTb4b4b4)
Tff7b72return Te6edf3packetId
Tb4b4b4}
T8b949e/**
* Requests a configuration section from the radio.
*
* @param destNum The node number to query.
* @param configType The type of configuration to request (from [org.meshtastic.proto.AdminMessage.ConfigType]).
* @param onRequestId Invoked with the request's packet ID before the send is issued.
* @return The packet ID of the request.
*/
Tff7b72open Tff7b72suspend Tff7b72fun Td2a8ffgetConfigTb4b4b4(Te6edf3destNumTb4b4b4: Tffa657IntTb4b4b4, Te6edf3configTypeTb4b4b4: Tffa657IntTb4b4b4, Te6edf3onRequestIdTb4b4b4: Tb4b4b4(Tffa657IntTb4b4b4) Tff7b72-Tff7b72> Tffa657Unit Tff7b72= Tb4b4b4{Tb4b4b4}Tb4b4b4)Tb4b4b4: Tffa657Int Tb4b4b4{
Tff7b72val Te6edf3packetId Tff7b72= Te6edf3radioControllerTb4b4b4.Te6edf3generatePacketIdTb4b4b4(Tb4b4b4)
Te6edf3onRequestIdTb4b4b4(Te6edf3packetIdTb4b4b4)
Te6edf3radioControllerTb4b4b4.Te6edf3getConfigTb4b4b4(Te6edf3destNumTb4b4b4, Te6edf3configTypeTb4b4b4, Te6edf3packetIdTb4b4b4)
Tff7b72return Te6edf3packetId
Tb4b4b4}
T8b949e/**
* Updates a module configuration section on the radio.
*
* @param destNum The node number to update.
* @param config The new module configuration.
* @param onRequestId Invoked with the request's packet ID before the send is issued.
* @return The packet ID of the request.
*/
Tff7b72open Tff7b72suspend Tff7b72fun Td2a8ffsetModuleConfigTb4b4b4(Te6edf3destNumTb4b4b4: Tffa657IntTb4b4b4, Te6edf3configTb4b4b4: Te6edf3ModuleConfigTb4b4b4, Te6edf3onRequestIdTb4b4b4: Tb4b4b4(Tffa657IntTb4b4b4) Tff7b72-Tff7b72> Tffa657Unit Tff7b72= Tb4b4b4{Tb4b4b4}Tb4b4b4)Tb4b4b4: Tffa657Int Tb4b4b4{
Tff7b72val Te6edf3packetId Tff7b72= Te6edf3radioControllerTb4b4b4.Te6edf3generatePacketIdTb4b4b4(Tb4b4b4)
Te6edf3onRequestIdTb4b4b4(Te6edf3packetIdTb4b4b4)
Te6edf3radioControllerTb4b4b4.Te6edf3setModuleConfigTb4b4b4(Te6edf3destNumTb4b4b4, Te6edf3configTb4b4b4, Te6edf3packetIdTb4b4b4)
Tff7b72return Te6edf3packetId
Tb4b4b4}
T8b949e/**
* Requests a module configuration section from the radio.
*
* @param destNum The node number to query.
* @param moduleConfigType The type of module configuration to request.
* @param onRequestId Invoked with the request's packet ID before the send is issued.
* @return The packet ID of the request.
*/
Tff7b72open Tff7b72suspend Tff7b72fun Td2a8ffgetModuleConfigTb4b4b4(Te6edf3destNumTb4b4b4: Tffa657IntTb4b4b4, Te6edf3moduleConfigTypeTb4b4b4: Tffa657IntTb4b4b4, Te6edf3onRequestIdTb4b4b4: Tb4b4b4(Tffa657IntTb4b4b4) Tff7b72-Tff7b72> Tffa657Unit Tff7b72= Tb4b4b4{Tb4b4b4}Tb4b4b4)Tb4b4b4: Tffa657Int Tb4b4b4{
Tff7b72val Te6edf3packetId Tff7b72= Te6edf3radioControllerTb4b4b4.Te6edf3generatePacketIdTb4b4b4(Tb4b4b4)
Te6edf3onRequestIdTb4b4b4(Te6edf3packetIdTb4b4b4)
Te6edf3radioControllerTb4b4b4.Te6edf3getModuleConfigTb4b4b4(Te6edf3destNumTb4b4b4, Te6edf3moduleConfigTypeTb4b4b4, Te6edf3packetIdTb4b4b4)
Tff7b72return Te6edf3packetId
Tb4b4b4}
T8b949e/**
* Requests a channel from the radio.
*
* @param destNum The node number to query.
* @param index The index of the channel to request.
* @param onRequestId Invoked with the request's packet ID before the send is issued.
* @return The packet ID of the request.
*/
Tff7b72open Tff7b72suspend Tff7b72fun Td2a8ffgetChannelTb4b4b4(Te6edf3destNumTb4b4b4: Tffa657IntTb4b4b4, Te6edf3indexTb4b4b4: Tffa657IntTb4b4b4, Te6edf3onRequestIdTb4b4b4: Tb4b4b4(Tffa657IntTb4b4b4) Tff7b72-Tff7b72> Tffa657Unit Tff7b72= Tb4b4b4{Tb4b4b4}Tb4b4b4)Tb4b4b4: Tffa657Int Tb4b4b4{
Tff7b72val Te6edf3packetId Tff7b72= Te6edf3radioControllerTb4b4b4.Te6edf3generatePacketIdTb4b4b4(Tb4b4b4)
Te6edf3onRequestIdTb4b4b4(Te6edf3packetIdTb4b4b4)
Te6edf3radioControllerTb4b4b4.Te6edf3getChannelTb4b4b4(Te6edf3destNumTb4b4b4, Te6edf3indexTb4b4b4, Te6edf3packetIdTb4b4b4)
Tff7b72return Te6edf3packetId
Tb4b4b4}
T8b949e/**
* Updates a channel on the radio.
*
* @param destNum The node number to update.
* @param channel The new channel configuration.
* @param onRequestId Invoked with the request's packet ID before the send is issued.
* @return The packet ID of the request.
*/
Tff7b72open Tff7b72suspend Tff7b72fun Td2a8ffsetRemoteChannelTb4b4b4(
Te6edf3destNumTb4b4b4: Tffa657IntTb4b4b4,
Te6edf3channelTb4b4b4: Te6edf3orgTb4b4b4.Te6edf3meshtasticTb4b4b4.Te6edf3protoTb4b4b4.Te6edf3ChannelTb4b4b4,
Te6edf3onRequestIdTb4b4b4: Tb4b4b4(Tffa657IntTb4b4b4) Tff7b72-Tff7b72> Tffa657Unit Tff7b72= Tb4b4b4{Tb4b4b4}Tb4b4b4,
Tb4b4b4)Tb4b4b4: Tffa657Int Tb4b4b4{
Tff7b72val Te6edf3packetId Tff7b72= Te6edf3radioControllerTb4b4b4.Te6edf3generatePacketIdTb4b4b4(Tb4b4b4)
Te6edf3onRequestIdTb4b4b4(Te6edf3packetIdTb4b4b4)
Te6edf3radioControllerTb4b4b4.Te6edf3setRemoteChannelTb4b4b4(Te6edf3destNumTb4b4b4, Te6edf3channelTb4b4b4, Te6edf3packetIdTb4b4b4)
Tff7b72return Te6edf3packetId
Tb4b4b4}
T8b949e/** Updates the fixed position on the radio. */
Tff7b72open Tff7b72suspend Tff7b72fun Td2a8ffsetFixedPositionTb4b4b4(Te6edf3destNumTb4b4b4: Tffa657IntTb4b4b4, Te6edf3positionTb4b4b4: Te6edf3PositionTb4b4b4) Tb4b4b4{
Te6edf3radioControllerTb4b4b4.Te6edf3setFixedPositionTb4b4b4(Te6edf3destNumTb4b4b4, Te6edf3positionTb4b4b4)
Tb4b4b4}
T8b949e/** Removes the fixed position on the radio. */
Tff7b72open Tff7b72suspend Tff7b72fun Td2a8ffremoveFixedPositionTb4b4b4(Te6edf3destNumTb4b4b4: Tffa657IntTb4b4b4) Tb4b4b4{
Te6edf3radioControllerTb4b4b4.Te6edf3setFixedPositionTb4b4b4(Te6edf3destNumTb4b4b4, Te6edf3PositionTb4b4b4(T79c0ff0.0Tb4b4b4, T79c0ff0.0Tb4b4b4, T79c0ff0Tb4b4b4)Tb4b4b4)
Tb4b4b4}
T8b949e/** Sets the ringtone on the radio. */
Tff7b72open Tff7b72suspend Tff7b72fun Td2a8ffsetRingtoneTb4b4b4(Te6edf3destNumTb4b4b4: Tffa657IntTb4b4b4, Te6edf3ringtoneTb4b4b4: Tffa657StringTb4b4b4) Tb4b4b4{
Te6edf3radioControllerTb4b4b4.Te6edf3setRingtoneTb4b4b4(Te6edf3destNumTb4b4b4, Te6edf3ringtoneTb4b4b4)
Tb4b4b4}
T8b949e/**
* Requests the ringtone from the radio.
*
* @param destNum The node number to query.
* @param onRequestId Invoked with the request's packet ID before the send is issued.
* @return The packet ID of the request.
*/
Tff7b72open Tff7b72suspend Tff7b72fun Td2a8ffgetRingtoneTb4b4b4(Te6edf3destNumTb4b4b4: Tffa657IntTb4b4b4, Te6edf3onRequestIdTb4b4b4: Tb4b4b4(Tffa657IntTb4b4b4) Tff7b72-Tff7b72> Tffa657Unit Tff7b72= Tb4b4b4{Tb4b4b4}Tb4b4b4)Tb4b4b4: Tffa657Int Tb4b4b4{
Tff7b72val Te6edf3packetId Tff7b72= Te6edf3radioControllerTb4b4b4.Te6edf3generatePacketIdTb4b4b4(Tb4b4b4)
Te6edf3onRequestIdTb4b4b4(Te6edf3packetIdTb4b4b4)
Te6edf3radioControllerTb4b4b4.Te6edf3getRingtoneTb4b4b4(Te6edf3destNumTb4b4b4, Te6edf3packetIdTb4b4b4)
Tff7b72return Te6edf3packetId
Tb4b4b4}
T8b949e/** Sets the canned messages on the radio. */
Tff7b72open Tff7b72suspend Tff7b72fun Td2a8ffsetCannedMessagesTb4b4b4(Te6edf3destNumTb4b4b4: Tffa657IntTb4b4b4, Te6edf3messagesTb4b4b4: Tffa657StringTb4b4b4) Tb4b4b4{
Te6edf3radioControllerTb4b4b4.Te6edf3setCannedMessagesTb4b4b4(Te6edf3destNumTb4b4b4, Te6edf3messagesTb4b4b4)
Tb4b4b4}
T8b949e/**
* Requests the canned messages from the radio.
*
* @param destNum The node number to query.
* @param onRequestId Invoked with the request's packet ID before the send is issued.
* @return The packet ID of the request.
*/
Tff7b72open Tff7b72suspend Tff7b72fun Td2a8ffgetCannedMessagesTb4b4b4(Te6edf3destNumTb4b4b4: Tffa657IntTb4b4b4, Te6edf3onRequestIdTb4b4b4: Tb4b4b4(Tffa657IntTb4b4b4) Tff7b72-Tff7b72> Tffa657Unit Tff7b72= Tb4b4b4{Tb4b4b4}Tb4b4b4)Tb4b4b4: Tffa657Int Tb4b4b4{
Tff7b72val Te6edf3packetId Tff7b72= Te6edf3radioControllerTb4b4b4.Te6edf3generatePacketIdTb4b4b4(Tb4b4b4)
Te6edf3onRequestIdTb4b4b4(Te6edf3packetIdTb4b4b4)
Te6edf3radioControllerTb4b4b4.Te6edf3getCannedMessagesTb4b4b4(Te6edf3destNumTb4b4b4, Te6edf3packetIdTb4b4b4)
Tff7b72return Te6edf3packetId
Tb4b4b4}
T8b949e/**
* Requests the device connection status from the radio.
*
* @param destNum The node number to query.
* @param onRequestId Invoked with the request's packet ID before the send is issued.
* @return The packet ID of the request.
*/
Tff7b72open Tff7b72suspend Tff7b72fun Td2a8ffgetDeviceConnectionStatusTb4b4b4(Te6edf3destNumTb4b4b4: Tffa657IntTb4b4b4, Te6edf3onRequestIdTb4b4b4: Tb4b4b4(Tffa657IntTb4b4b4) Tff7b72-Tff7b72> Tffa657Unit Tff7b72= Tb4b4b4{Tb4b4b4}Tb4b4b4)Tb4b4b4: Tffa657Int Tb4b4b4{
Tff7b72val Te6edf3packetId Tff7b72= Te6edf3radioControllerTb4b4b4.Te6edf3generatePacketIdTb4b4b4(Tb4b4b4)
Te6edf3onRequestIdTb4b4b4(Te6edf3packetIdTb4b4b4)
Te6edf3radioControllerTb4b4b4.Te6edf3getDeviceConnectionStatusTb4b4b4(Te6edf3destNumTb4b4b4, Te6edf3packetIdTb4b4b4)
Tff7b72return Te6edf3packetId
Tb4b4b4}
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.07s